### R Code for Study 1, Lucid Data ###

# Load Study1_LucidData.csv #
ExpData <- read.table(file.choose(), header = TRUE, sep = ",")

# Separate Fracking Data #
ExpData$FrackExp <- 0
ExpData$FrackExp[!is.na(ExpData$Q90)] <- 1
ExpData$FrackExp[!is.na(ExpData$Q91)] <- 1
table(ExpData$FrackExp)

ExpData <- ExpData[ExpData$FrackExp == 1, ]

# Fracking Attitude and Agree #
ExpData$FrAttitude <- ifelse(!is.na(ExpData$Q90), ExpData$Q90, ExpData$Q91)
table(ExpData$FrAttitude)

ExpData$FrackAgree <- ifelse(ExpData$FrAttitude < 3, 1, 0)
table(ExpData$FrackAgree)

# Treatment coded 1 if treatment (episodic), 0 if control (thematic)
ExpData$FrTreat <- ifelse(!is.na(ExpData$Q91), 1, 0)
table(ExpData$FrTreat)

# Extremity coded high numbers if extreme #
ExpData$FrExtremity <- abs(3 - ExpData$FrAttitude)
table(ExpData$FrExtremity)
ExpData$FrExtremity <- ExpData$FrExtremity/2
table(ExpData$FrExtremity)

# Importance coded high numbers if important
ExpData$FrImportance <- 5 - ExpData$Q83
table(ExpData$FrImportance)
ExpData$FrImportance <- ExpData$FrImportance/4
table(ExpData$FrImportance)

# Personal Salience coded high numbers if decision affects you 
ExpData$FrPersonalSalience <- 5 - ExpData$Q84
table(ExpData$FrPersonalSalience)
ExpData$FrPersonalSalience <- ExpData$FrPersonalSalience/4
table(ExpData$FrPersonalSalience)

# Moral Conviction 1 -- High numbers indicate moralized
ExpData$FrMoral1 <- 5 - ExpData$Q85
table(ExpData$FrMoral1)

# Moral Conviction 2 -- High numbers indicate moralized
ExpData$FrMoral2 <- 5 - ExpData$Q86
table(ExpData$FrMoral2)

# Full Moral, High numbers means high moral
ExpData$FrMoralFull <- ExpData$FrMoral1 + ExpData$FrMoral2
table(ExpData$FrMoralFull)
ExpData$FrMoralFull <- ExpData$FrMoralFull/8
table(ExpData$FrMoralFull)

cor(ExpData$FrMoralFull, ExpData$FrPersonalSalience, use = "pairwise.complete.obs")
cor(ExpData$FrMoralFull, ExpData$FrImportance, use = "pairwise.complete.obs")
cor(ExpData$FrMoralFull, ExpData$FrExtremity, use = "pairwise.complete.obs")

ExpData$Anger <- ExpData$Q87_1
ExpData$Disgust <- ExpData$Q87_2
ExpData$Sadness <- ExpData$Q87_3
ExpData$Anxiety <- ExpData$Q87_4
ExpData$Fear <- ExpData$Q87_5

emodat <- c("Anger", "Disgust",
            "Sadness", "Anxiety", "Fear")

emodata <- ExpData[emodat]

emodata <- na.omit(emodata)

# Cronbach's for emo scale #
library(psych)
alpha(emodata)

ExpData$AllEmo <- ExpData$Anger + ExpData$Disgust + 
  ExpData$Sadness + ExpData$Anxiety + ExpData$Fear
table(ExpData$AllEmo)
ExpData$AllEmo <- ExpData$AllEmo - 5
table(ExpData$AllEmo)
ExpData$AllEmo <- ExpData$AllEmo/20
table(ExpData$AllEmo)

ExpData$Anger <- (ExpData$Anger - 1)/4
table(ExpData$Anger)
ExpData$Disgust <- (ExpData$Disgust - 1)/4
table(ExpData$Disgust)
ExpData$Sadness <- (ExpData$Sadness - 1)/4
table(ExpData$Sadness)
ExpData$Anxiety <- (ExpData$Anxiety - 1)/4
table(ExpData$Anxiety)
ExpData$Fear <- (ExpData$Fear - 1)/4
table(ExpData$Fear)

# Fitting SUR Mods #
library(systemfit)

e1 <- FrMoralFull ~ FrTreat
e2 <- FrPersonalSalience ~ FrTreat
e3 <- FrImportance ~ FrTreat
e4 <- FrExtremity ~ FrTreat

SURVars <- c("FrMoralFull", "FrImportance", "FrPersonalSalience",
             "FrExtremity", "FrTreat")

ExpData1 <- ExpData[SURVars]
ExpData1 <- na.omit(ExpData1)

fitsur <- systemfit(list(Moral = e1, PerSal = e2, Imp = e3, Ext = e4), 
                    data=ExpData1)
summary(fitsur)

library(car)
rest1 <- "Moral_FrTreat - PerSal_FrTreat"
linearHypothesis(fitsur, rest1, test = "F")

rest2 <- "Moral_FrTreat - Imp_FrTreat"
linearHypothesis(fitsur, rest2, test = "F")

rest3 <- "Moral_FrTreat - Ext_FrTreat"
linearHypothesis(fitsur, rest3, test = "F")

# Treatment conditional on agree/disagree (supp material) #

e5 <- FrMoralFull ~ FrTreat*FrackAgree
e6 <- FrPersonalSalience ~ FrTreat*FrackAgree
e7 <- FrImportance ~ FrTreat*FrackAgree
e8 <- FrExtremity ~ FrTreat*FrackAgree

SURVars2 <- c("FrMoralFull", "FrImportance", "FrPersonalSalience",
              "FrExtremity", "FrTreat", "FrackAgree")

ExpData2 <- ExpData[SURVars2]
ExpData3 <- na.omit(ExpData2)

fitsur2 <- systemfit(list(Moral = e5, PerSal = e6, Imp = e7, Ext = e8), 
                     data=ExpData3)
summary(fitsur2)

# Pol vars and demos for mediation analyses #

ExpData$Ind <- 0
ExpData$Ind[ExpData$political_party == 4] <- 1
ExpData$Ind[ExpData$political_party == 7] <- 1

ExpData$Dem <- 0
ExpData$Dem[ExpData$political_party == 1] <- 1
ExpData$Dem[ExpData$political_party == 2] <- 1
ExpData$Dem[ExpData$political_party == 3] <- 1
ExpData$Dem[ExpData$political_party == 6] <- 1

ExpData$Rep <- 0
ExpData$Rep[ExpData$political_party == 5] <- 1
ExpData$Rep[ExpData$political_party == 8] <- 1
ExpData$Rep[ExpData$political_party == 9] <- 1
ExpData$Rep[ExpData$political_party == 10] <- 1

ExpData$Conserv <- ExpData$Q32
table(ExpData$Ind)
table(ExpData$Dem)
table(ExpData$Rep)
table(ExpData$Conserv)

ExpData$Female <- ifelse(ExpData$gender == 2, 1, 0)
table(ExpData$Female)

ExpData$Age <- ExpData$Q78
table(ExpData$Age)

MedVars <- c("FrTreat", "FrMoralFull", "AllEmo","FrExtremity",
             "FrImportance", "FrPersonalSalience", "Ind", "Dem",
             "Rep", "Conserv", "Female", "Age", "Anger", "Disgust",
             "Sadness", "Anxiety", "Fear")

MedData <- ExpData[MedVars]
MedData <- na.omit(MedData)
#MedData$Conserv <- MedData$Ideol
MedData$Ideol <- MedData$Conserv

library(mediation)

# Full Emo Scale -- Moral Conviction #
set.seed(12345)
med.fit.emo1 <- lm(AllEmo ~ FrTreat + Dem + Rep + Conserv + Female + Age, 
                   data = MedData)
out.fit.emo1 <- lm(FrMoralFull ~ AllEmo + FrTreat + Dem + Rep + 
                     Conserv + Age + FrExtremity + FrPersonalSalience +
                     FrImportance, data = MedData)
med.out.emo1 <- mediate(med.fit.emo1, out.fit.emo1, treat = "FrTreat",
                        mediator = "AllEmo", robustSE = TRUE, 
                        sims = 2000)
summary(med.out.emo1)

# Full Scale, Extremity #
set.seed(12345)
med.fit.emo19 <- lm(AllEmo ~ FrTreat + Dem + Rep + Ideol + Female + Age, 
                    data = MedData)
out.fit.emo19 <- lm(FrExtremity ~ AllEmo + FrTreat + Dem + Rep + 
                      Ideol + Age + FrMoralFull + FrImportance +
                      FrPersonalSalience, data = MedData)
med.out.emo19 <- mediate(med.fit.emo19, out.fit.emo19, treat = "FrTreat",
                         mediator = "AllEmo", robustSE = TRUE, 
                         sims = 2000)
summary(med.out.emo19)

# Full Scale -- Importance
set.seed(12345)
med.fit.emo13 <- lm(AllEmo ~ FrTreat + Dem + Rep + Ideol + Female + Age, 
                    data = MedData)
out.fit.emo13 <- lm(FrImportance ~ AllEmo + FrTreat + Dem + Rep + 
                      Ideol + Age + FrMoralFull + FrExtremity +
                      FrPersonalSalience, data = MedData)
med.out.emo13 <- mediate(med.fit.emo13, out.fit.emo13, treat = "FrTreat",
                         mediator = "AllEmo", robustSE = TRUE, 
                         sims = 2000)
summary(med.out.emo13)

# Full Scale -- Pers salience
set.seed(12345)
med.fit.emo7 <- lm(AllEmo ~ FrTreat + Dem + Rep + Ideol + Female + Age, 
                   data = MedData)
out.fit.emo7 <- lm(FrPersonalSalience ~ AllEmo + FrTreat + Dem + Rep + 
                     Ideol + Age + FrMoralFull + FrImportance +
                     FrExtremity, data = MedData)
med.out.emo7 <- mediate(med.fit.emo7, out.fit.emo7, treat = "FrTreat",
                        mediator = "AllEmo", robustSE = TRUE, 
                        sims = 2000)
summary(med.out.emo7)

### Multiple Mediators (Supp Material) ###

ExpData$Ideol <- ExpData$Conserv

MedVars <- c("FrTreat", "FrMoralFull", "AllEmo","FrExtremity",
             "FrImportance", "FrPersonalSalience", "Ind", "Dem",
             "Rep", "Ideol", "Female", "Age", "Anger", "Disgust",
             "Sadness", "Anxiety", "Fear")

MedData <- ExpData[MedVars]
MedData <- na.omit(MedData)

### Moral Conviction ###

# Anger #
set.seed(12345)
m.med_anger_moralconv95 <- multimed(outcome = "FrMoralFull", med.main = "Anger",
                                    med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                                    treat = "FrTreat",
                                    covariates = c("FrExtremity", "FrImportance",
                                                   "FrPersonalSalience",
                                                   "Dem", "Rep", "Ideol", 
                                                   "Female", "Age"),
                                    data = MedData, sims = 2000,
                                    conf.level = .95)
summary(m.med_anger_moralconv95)

set.seed(12345)
m.med_anger_moralconv99 <- multimed(outcome = "FrMoralFull", med.main = "Anger",
                                    med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                                    treat = "FrTreat",
                                    covariates = c("FrExtremity", "FrImportance",
                                                   "FrPersonalSalience",
                                                   "Dem", "Rep", "Ideol", 
                                                   "Female", "Age"),
                                    data = MedData, sims = 2000,
                                    conf.level = .99)
summary(m.med_anger_moralconv99)

# Disgust #
set.seed(12345)
m.med_disgust_moralconv95 <- multimed(outcome = "FrMoralFull", med.main = "Disgust",
                                      med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                      treat = "FrTreat",
                                      covariates = c("FrExtremity", "FrImportance",
                                                     "FrPersonalSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .95)
summary(m.med_disgust_moralconv95)

set.seed(12345)
m.med_disgust_moralconv99 <- multimed(outcome = "FrMoralFull", med.main = "Disgust",
                                      med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                      treat = "FrTreat",
                                      covariates = c("FrExtremity", "FrImportance",
                                                     "FrPersonalSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .99)
summary(m.med_disgust_moralconv99)


# Anxiety #
set.seed(12345)
m.med_anxiety_moralconv95 <- multimed(outcome = "FrMoralFull", med.main = "Anxiety",
                                      med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                      treat = "FrTreat",
                                      covariates = c("FrExtremity", "FrImportance",
                                                     "FrPersonalSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .95)
summary(m.med_anxiety_moralconv95)

set.seed(12345)
m.med_anxiety_moralconv99 <- multimed(outcome = "FrMoralFull", med.main = "Anxiety",
                                      med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                      treat = "FrTreat",
                                      covariates = c("FrExtremity", "FrImportance",
                                                     "FrPersonalSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .99)
summary(m.med_anxiety_moralconv99)

# Sadness #
set.seed(12345)
m.med_sadness_moralconv95 <- multimed(outcome = "FrMoralFull", med.main = "Sadness",
                                      med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                      treat = "FrTreat",
                                      covariates = c("FrExtremity", "FrImportance",
                                                     "FrPersonalSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .95)
summary(m.med_sadness_moralconv95)

set.seed(12345)
m.med_sadness_moralconv99 <- multimed(outcome = "FrMoralFull", med.main = "Sadness",
                                      med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                      treat = "FrTreat",
                                      covariates = c("FrExtremity", "FrImportance",
                                                     "FrPersonalSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .99)
summary(m.med_sadness_moralconv99)


# Fear #
set.seed(12345)
m.med_fear_moralconv95 <- multimed(outcome = "FrMoralFull", med.main = "Fear",
                                   med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrPersonalSalience",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_fear_moralconv95)

set.seed(12345)
m.med_fear_moralconv99 <- multimed(outcome = "FrMoralFull", med.main = "Fear",
                                   med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrPersonalSalience",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_fear_moralconv99)


### Personal Salience ###

# Anger #
set.seed(12345)
m.med_anger_persal95 <- multimed(outcome = "FrPersonalSalience", med.main = "Anger",
                                 med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                                 treat = "FrTreat",
                                 covariates = c("FrExtremity", "FrImportance",
                                                "FrMoralFull",
                                                "Dem", "Rep", "Ideol", 
                                                "Female", "Age"),
                                 data = MedData, sims = 2000,
                                 conf.level = .95)
summary(m.med_anger_persal95)

set.seed(12345)
m.med_anger_persal99 <- multimed(outcome = "FrPersonalSalience", med.main = "Anger",
                                 med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                                 treat = "FrTreat",
                                 covariates = c("FrExtremity", "FrImportance",
                                                "FrMoralFull",
                                                "Dem", "Rep", "Ideol", 
                                                "Female", "Age"),
                                 data = MedData, sims = 2000,
                                 conf.level = .99)
summary(m.med_anger_persal99)

# Disgust #
set.seed(12345)
m.med_disgust_persal95 <- multimed(outcome = "FrPersonalSalience", med.main = "Disgust",
                                   med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_disgust_persal95)

set.seed(12345)
m.med_disgust_persal99 <- multimed(outcome = "FrPersonalSalience", med.main = "Disgust",
                                   med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_disgust_persal99)

# Anxiety #
set.seed(12345)
m.med_anxiety_persal95 <- multimed(outcome = "FrPersonalSalience", med.main = "Anxiety",
                                   med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_anxiety_persal95)

set.seed(12345)
m.med_anxiety_persal99 <- multimed(outcome = "FrPersonalSalience", med.main = "Anxiety",
                                   med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_anxiety_persal99)

# Sadness #
set.seed(12345)
m.med_sadness_persal95 <- multimed(outcome = "FrPersonalSalience", med.main = "Sadness",
                                   med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_sadness_persal95)

set.seed(12345)
m.med_sadness_persal99 <- multimed(outcome = "FrPersonalSalience", med.main = "Sadness",
                                   med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                   treat = "FrTreat",
                                   covariates = c("FrExtremity", "FrImportance",
                                                  "FrMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_sadness_persal99)


# Fear #
set.seed(12345)
m.med_fear_persal95 <- multimed(outcome = "FrPersonalSalience", med.main = "Fear",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrImportance",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_fear_persal95)

set.seed(12345)
m.med_fear_persal99 <- multimed(outcome = "FrPersonalSalience", med.main = "Fear",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrImportance",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_fear_persal99)


### Attitude Importance ###

# Anger #
set.seed(12345)
m.med_anger_imp95 <- multimed(outcome = "FrImportance", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                              treat = "FrTreat",
                              covariates = c("FrExtremity", "FrPersonalSalience",
                                             "FrMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .95)
summary(m.med_anger_imp95)

set.seed(12345)
m.med_anger_imp99 <- multimed(outcome = "FrImportance", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                              treat = "FrTreat",
                              covariates = c("FrExtremity", "FrPersonalSalience",
                                             "FrMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .99)
summary(m.med_anger_imp99)

# Disgust #
set.seed(12345)
m.med_disgust_imp95 <- multimed(outcome = "FrImportance", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_disgust_imp95)

set.seed(12345)
m.med_disgust_imp99 <- multimed(outcome = "FrImportance", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_disgust_imp99)

# Anxiety #
set.seed(12345)
m.med_anxiety_imp95 <- multimed(outcome = "FrImportance", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_anxiety_imp95)

set.seed(12345)
m.med_anxiety_imp99 <- multimed(outcome = "FrImportance", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_anxiety_imp99)

# Sadness #
set.seed(12345)
m.med_sadness_imp95 <- multimed(outcome = "FrImportance", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_sadness_imp95)

set.seed(12345)
m.med_sadness_imp99 <- multimed(outcome = "FrImportance", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrExtremity", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_sadness_imp99)

# Fear #
set.seed(12345)
m.med_fear_imp95 <- multimed(outcome = "FrImportance", med.main = "Fear",
                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                             treat = "FrTreat",
                             covariates = c("FrExtremity", "FrPersonalSalience",
                                            "FrMoralFull",
                                            "Dem", "Rep", "Ideol", 
                                            "Female", "Age"),
                             data = MedData, sims = 2000,
                             conf.level = .95)
summary(m.med_fear_imp95)

set.seed(12345)
m.med_fear_imp99 <- multimed(outcome = "FrImportance", med.main = "Fear",
                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                             treat = "FrTreat",
                             covariates = c("FrExtremity", "FrPersonalSalience",
                                            "FrMoralFull",
                                            "Dem", "Rep", "Ideol", 
                                            "Female", "Age"),
                             data = MedData, sims = 2000,
                             conf.level = .99)
summary(m.med_fear_imp99)


# Attitude Extremity #

# Anger #
set.seed(12345)
m.med_anger_ext95 <- multimed(outcome = "FrExtremity", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                              treat = "FrTreat",
                              covariates = c("FrImportance", "FrPersonalSalience",
                                             "FrMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .95)
summary(m.med_anger_ext95)

set.seed(12345)
m.med_anger_ext99 <- multimed(outcome = "FrExtremity", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                              treat = "FrTreat",
                              covariates = c("FrImportance", "FrPersonalSalience",
                                             "FrMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .99)
summary(m.med_anger_ext99)

# Disgust #
set.seed(12345)
m.med_disgust_ext95 <- multimed(outcome = "FrExtremity", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrImportance", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_disgust_ext95)

set.seed(12345)
m.med_disgust_ext99 <- multimed(outcome = "FrExtremity", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrImportance", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_disgust_ext99)

# Anxiety #
set.seed(12345)
m.med_anxiety_ext95 <- multimed(outcome = "FrExtremity", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrImportance", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_anxiety_ext95)

set.seed(12345)
m.med_anxiety_ext99 <- multimed(outcome = "FrExtremity", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrImportance", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_anxiety_ext99)

# Sadness #
set.seed(12345)
m.med_sadness_ext95 <- multimed(outcome = "FrExtremity", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrImportance", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_sadness_ext95)

set.seed(12345)
m.med_sadness_ext99 <- multimed(outcome = "FrExtremity", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                treat = "FrTreat",
                                covariates = c("FrImportance", "FrPersonalSalience",
                                               "FrMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_sadness_ext99)


# Fear #
set.seed(12345)
m.med_fear_ext95 <- multimed(outcome = "FrExtremity", med.main = "Fear",
                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                             treat = "FrTreat",
                             covariates = c("FrImportance", "FrPersonalSalience",
                                            "FrMoralFull",
                                            "Dem", "Rep", "Ideol", 
                                            "Female", "Age"),
                             data = MedData, sims = 2000,
                             conf.level = .95)
summary(m.med_fear_ext95)

set.seed(12345)
m.med_fear_ext99 <- multimed(outcome = "FrExtremity", med.main = "Fear",
                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
                             treat = "FrTreat",
                             covariates = c("FrImportance", "FrPersonalSalience",
                                            "FrMoralFull",
                                            "Dem", "Rep", "Ideol", 
                                            "Female", "Age"),
                             data = MedData, sims = 2000,
                             conf.level = .99)
summary(m.med_fear_ext99)

### Checking results conditioned on satisficing (supp material) ###

# clearing and reloading data
rm(list=ls())

# Load Study1_LucidData.csv #
ExpData <- read.table(file.choose(), header = TRUE, sep = ",")

# Separate Fracking Data #
ExpData$FrackExp <- 0
ExpData$FrackExp[!is.na(ExpData$Q90)] <- 1
ExpData$FrackExp[!is.na(ExpData$Q91)] <- 1
table(ExpData$FrackExp)

ExpData <- ExpData[ExpData$FrackExp == 1, ]

# Fracking Attitude and Agree #
ExpData$FrAttitude <- ifelse(!is.na(ExpData$Q90), ExpData$Q90, ExpData$Q91)
table(ExpData$FrAttitude)

ExpData$FrackAgree <- ifelse(ExpData$FrAttitude < 3, 1, 0)
table(ExpData$FrackAgree)

# Treatment coded 1 if treatment (episodic), 0 if control (thematic)
ExpData$FrTreat <- ifelse(!is.na(ExpData$Q91), 1, 0)
table(ExpData$FrTreat)

# Extremity coded high numbers if extreme #
ExpData$FrExtremity <- abs(3 - ExpData$FrAttitude)
table(ExpData$FrExtremity)
ExpData$FrExtremity <- ExpData$FrExtremity/2
table(ExpData$FrExtremity)

# Importance coded high numbers if important
ExpData$FrImportance <- 5 - ExpData$Q83
table(ExpData$FrImportance)
ExpData$FrImportance <- ExpData$FrImportance/4
table(ExpData$FrImportance)

# Personal Salience coded high numbers if decision affects you 
ExpData$FrPersonalSalience <- 5 - ExpData$Q84
table(ExpData$FrPersonalSalience)
ExpData$FrPersonalSalience <- ExpData$FrPersonalSalience/4
table(ExpData$FrPersonalSalience)

# Moral Conviction 1 -- High numbers indicate moralized
ExpData$FrMoral1 <- 5 - ExpData$Q85
table(ExpData$FrMoral1)

# Moral Conviction 2 -- High numbers indicate moralized
ExpData$FrMoral2 <- 5 - ExpData$Q86
table(ExpData$FrMoral2)

# Full Moral, High numbers means high moral
ExpData$FrMoralFull <- ExpData$FrMoral1 + ExpData$FrMoral2
table(ExpData$FrMoralFull)
ExpData$FrMoralFull <- ExpData$FrMoralFull/8
table(ExpData$FrMoralFull)

cor(ExpData$FrMoralFull, ExpData$FrPersonalSalience, use = "pairwise.complete.obs")
cor(ExpData$FrMoralFull, ExpData$FrImportance, use = "pairwise.complete.obs")
cor(ExpData$FrMoralFull, ExpData$FrExtremity, use = "pairwise.complete.obs")

ExpData$Anger <- ExpData$Q87_1
ExpData$Disgust <- ExpData$Q87_2
ExpData$Sadness <- ExpData$Q87_3
ExpData$Anxiety <- ExpData$Q87_4
ExpData$Fear <- ExpData$Q87_5

emodat <- c("Anger", "Disgust",
            "Sadness", "Anxiety", "Fear")

emodata <- ExpData[emodat]

emodata <- na.omit(emodata)

# Cronbach's for emo scale #
library(psych)
alpha(emodata)

ExpData$AllEmo <- ExpData$Anger + ExpData$Disgust + 
  ExpData$Sadness + ExpData$Anxiety + ExpData$Fear
table(ExpData$AllEmo)
ExpData$AllEmo <- ExpData$AllEmo - 5
table(ExpData$AllEmo)
ExpData$AllEmo <- ExpData$AllEmo/20
table(ExpData$AllEmo)

ExpData$Anger <- (ExpData$Anger - 1)/4
table(ExpData$Anger)
ExpData$Disgust <- (ExpData$Disgust - 1)/4
table(ExpData$Disgust)
ExpData$Sadness <- (ExpData$Sadness - 1)/4
table(ExpData$Sadness)
ExpData$Anxiety <- (ExpData$Anxiety - 1)/4
table(ExpData$Anxiety)
ExpData$Fear <- (ExpData$Fear - 1)/4
table(ExpData$Fear)

# value at 10th percentile is 224.6
quantile(ExpData$Duration..in.seconds., c(.1))
ExpData$Short <- ifelse(ExpData$Duration < 224.6, 1, 0)
table(ExpData$Short)

e9 <- FrMoralFull ~ FrTreat*Short
e10 <- FrPersonalSalience ~ FrTreat*Short
e11 <- FrImportance ~ FrTreat*Short
e12 <- FrExtremity ~ FrTreat*Short

SURVars3 <- c("FrMoralFull", "FrImportance", "FrPersonalSalience",
              "FrExtremity", "FrTreat", "Short")

ExpData4 <- ExpData[SURVars3]
ExpData5 <- na.omit(ExpData4)

fitsur3 <- systemfit(list(Moral = e9, PerSal = e10, Imp = e11, Ext = e12), 
                     data=ExpData5)
summary(fitsur3)

### Straight lining (Supp Material) ###

# coding straightlining, q62-66
table(ExpData$Q62) # coded 1-5

table(ExpData$Q63) #coded 12468
ExpData$Q63_1[ExpData$Q63 == 1] <- 1
ExpData$Q63_1[ExpData$Q63 == 2] <- 2
ExpData$Q63_1[ExpData$Q63 == 4] <- 3
ExpData$Q63_1[ExpData$Q63 == 6] <- 4
ExpData$Q63_1[ExpData$Q63 == 8] <- 5
table(ExpData$Q63_1)

table(ExpData$Q64) # coded 1-5

table(ExpData$Q65)
ExpData$Q65_1[ExpData$Q65 == 8] <- 1
ExpData$Q65_1[ExpData$Q65 == 9] <- 2
ExpData$Q65_1[ExpData$Q65 == 10] <- 3
ExpData$Q65_1[ExpData$Q65 == 11] <- 4
ExpData$Q65_1[ExpData$Q65 == 12] <- 5
table(ExpData$Q65_1)

table(ExpData$Q66)
ExpData$Q66_1[ExpData$Q66 == 8] <- 1
ExpData$Q66_1[ExpData$Q66 == 9] <- 2
ExpData$Q66_1[ExpData$Q66 == 10] <- 3
ExpData$Q66_1[ExpData$Q66 == 11] <- 4
ExpData$Q66_1[ExpData$Q66 == 12] <- 5
table(ExpData$Q66_1)

ExpData$Straight <- ifelse(ExpData$Q62 == ExpData$Q63_1 &
                             ExpData$Q62 == ExpData$Q64 &
                             ExpData$Q62 == ExpData$Q65_1 &
                             ExpData$Q62 == ExpData$Q66_1, 1, 0)
table(ExpData$Straight)

e13 <- FrMoralFull ~ FrTreat*Straight
e14 <- FrPersonalSalience ~ FrTreat*Straight
e15 <- FrImportance ~ FrTreat*Straight
e16 <- FrExtremity ~ FrTreat*Straight

SURVars4 <- c("FrMoralFull", "FrImportance", "FrPersonalSalience",
              "FrExtremity", "FrTreat", "Straight")

ExpData6 <- ExpData[SURVars4]
ExpData7 <- na.omit(ExpData6)

fitsur4 <- systemfit(list(Moral = e13, PerSal = e14, Imp = e15, Ext = e16), 
                     data=ExpData7)
summary(fitsur4)
